using System.Web.Mvc;
using UnitTestDemo.Models;

namespace UnitTestDemo.Controllers
{
    public class AdminController:Controller
    {
        private readonly IRepository _repository;

        public AdminController(IRepository repository)
        {
            _repository = repository;
        }

        public ActionResult ChangeLoginName(string oldName, string newName)
        {
            var user = _repository.FetchByLoginName(oldName);
            user.LoginName = newName;
            _repository.SubmitChanges();
            return View();
        }
    }
}